package com.wze.wze.Util;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

@Component
public class RedisTool {
    public Jedis getJedis(){
        Jedis jedis = null;
        try {
jedis = new Jedis("110.42.138.101",6379);//设置连接地址
            jedis.auth("123456");//设置密码
            jedis.select(0);//连接数据库
            System.out.println("连接成功！");
        }catch (Exception e){
        System.out.println("连接失败"+e.getMessage());
        }finally {
            if(jedis!=null){
                try {
                    jedis.close();
                }catch (Exception e){
                    System.out.println("关闭失败"+e.getMessage());
                }
            }
        }
        return jedis;
    }
}
